var treePanel;
function getTree()
{
	var store = Ext.create('Ext.data.TreeStore', 
	{
        root: 
        {
            text: 'System',
            id: 'root',
            expanded: true
        },
		proxy: 
        {
            type: 'ajax',
            url: 'TreeServlet',
            extraParams:
            {
            	mode:'getChildren'
            },
            reader:
            {
            	type:'json',
            	root:'result'
            }
        }
    });
	
	treePanel=Ext.create('Ext.tree.Panel', 
    {
        region:'west',
        split:true,
        width: 250,
        height:400,
        title:'Menu',
        collapsible:true,
		store: store,
        rootVisible: true,
        useArrows: true,
        frame: false,
        listeners:
    	{
        	cellclick:function(table,td,cellIndex,record,tr,rowIndex,e,eOpts)
        	{
        		var url=record.raw.url;
        		var text=record.raw.text;
        		var id=record.raw.id;
        		
        		if (url==undefined)
        			return;
        		
        		addTab(id,text,url);
        	}
    	}
    });
	
	
	return treePanel;
}
